package com.keshe.order.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.keshe.common.utils.R;
import com.keshe.order.entity.ReturnEntity;
import com.keshe.order.service.ReturnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("order/return")
public class ReturnController {

    @Autowired
    ReturnService returnService;

    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        IPage<ReturnEntity> pageInfo = returnService.getReturnList(params);

        return R.ok().put("page", pageInfo);
    }

    @RequestMapping("/update")
    public R update(@RequestBody ReturnEntity returnEntity) {
        returnService.updateById(returnEntity);
        return R.ok();
    }

    @RequestMapping("/info/{returnId}")
    public R info(@PathVariable("returnId") Integer returnId) {
        ReturnEntity returnInfo = returnService.getReturnInfo(returnId);

        return R.ok().put("returnInfo", returnInfo);
    }
}
